<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>居中显示</title>
    <style>
        .container {
            width:400px;
            height:400px;
            margin:0 auto;
            background-color:#888;
            position:relative;
        }
        .context {
            height: 30px;
            width:70px;
            background-color: blue;
            margin:auto;
            position:absolute;
            left:0px;
            right:0px;
            top:0px;
            bottom:0px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="context">这是内容</div>
    </div>
</body>
</html>